using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public interface IShopBuyable {
	string DisplayName();
	PriceCurrency GetPrice();
	string GetImagePath();
}

public class ShopInventory {
	public List<IShopBuyable> buyables;
	
	public ShopInventory() {
		this.buyables = new List<IShopBuyable>();
	}
}

public class Shop {
	protected ShopInventory inventory;
	
	public Shop() {
		this.inventory = new ShopInventory();	
	}
	
	public IShopBuyable GetBuyableAt(int index) {
		if (index < this.inventory.buyables.Count) {
			return this.inventory.buyables[index];
		} else {
			return null;
		}
	}
	
	public IEnumerator GetBuyableEnumerator() {
		return this.inventory.buyables.GetEnumerator();
	}
}

/* Inventory must be of type Item */
public class ItemShop : Shop {
	
	public bool AddItem(string name) {
		this.inventory.buyables.Add (new Item(name));
		return true;
	}
	
	/* Get an ItemStack of an item at index */
	public ItemStack GetItemStackOfIndex(int index, int amount=1) {
		Item i;
		
		i = (Item)this.GetBuyableAt(index);
		if (i == null) {
			return null;
		}
		
		return new ItemStack(i, amount);
	}
}

